package cn.jtcoding.order.service.impl.feign;


import cn.jtcoding.common.framework.vo.ApiResult;
import cn.jtcoding.order.service.impl.feign.fallback.UserAddressFeignFallbackFactory;
import cn.jtcoding.user.pojo.bo.UserAddressBO;
import cn.jtcoding.user.pojo.dataobject.UserAddressDO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@FeignClient(
        name = "user-server",
        path = "/address",
        fallbackFactory = UserAddressFeignFallbackFactory.class)
public interface UserAddressFeignService {
    /**
     * 根据用户id查询用户的收货地址列表
     */
    @GetMapping("/list")
    ApiResult<List<UserAddressBO>> listUserAddress(@RequestParam("userId") String userId);

    /**
     * 用户新增地址
     */
    @PostMapping("/add")
    void addUserAddress(@RequestBody UserAddressBO userAddressBO);

    /**
     * 用户修改地址
     */
    @PostMapping("/update")
    void updateUserAddress(@RequestBody UserAddressBO userAddressBO);

    /**
     * 根据用户id和地址id，删除对应的用户地址信息
     */
    @PostMapping("/delete")
    void deleteUserAddress(@RequestParam("userId") String userId, @RequestParam("addressId") String addressId);

    /**
     * 修改默认地址
     */
    @PostMapping("/setDefalut")
    void updateUserAddressToBeDefault(@RequestParam("userId") String userId, @RequestParam("addressId") String addressId);

    /**
     * 根据用户id和地址id，查询具体的用户地址对象信息
     */
    @GetMapping("/{userId}/{addressId}")
    ApiResult<UserAddressDO> queryUserAddress(@PathVariable("userId") String userId, @PathVariable("addressId") String addressId);
}
